package design

import (
	"github.com/goadesign/goa/design/apidsl"
)

var _ = apidsl.API("antevent", func() { // API defines the microservice endpoint and
	apidsl.Title("蚁动事件引擎")           // other global properties. There should be one
	apidsl.Description("这是一个事件服务引擎") // and exactly one API definition appearing in
	apidsl.Scheme("http")            // the design.
	apidsl.Host("localhost:8080")
	apidsl.Consumes("application/json") // Media types supported by the API
	apidsl.Produces("application/json") // Media types generated by the API
	apidsl.BasePath("/v1")
	apidsl.Security(apidsl.OAuth2Security("antoAuth", func() {
		//apidsl.AccessCodeFlow("/authorization", "/token")
		//apidsl.ImplicitFlow("/authorization")
		//apidsl.PasswordFlow("/token")
		apidsl.ApplicationFlow("/token")

		//apidsl.Scope("my_system:write", "Write to the system")
		//apidsl.Scope("my_system:read", "Read anything in there")
	}))

	apidsl.Origin("*", func() {
		apidsl.Headers("authorization, content-type") // One or more authorized headers, use "*" to authorize all
		apidsl.Methods("GET", "POST", "PUT", "DELETE")
		apidsl.MaxAge(600)
		apidsl.Credentials()
		apidsl.Expose("X-Time")
	})

	// apidsl.ResponseTemplate(design.OK, func(mt string) {
	// 	apidsl.Status(200) // OK response uses status code 200
	// 	apidsl.Media(mt)   // Media type name set by action definition

	// 	apidsl.Headers(func() {
	// 		apidsl.Header("X-Request-Id", func() { // X-Request-Id header contains a string
	// 			apidsl.Pattern("[0-9A-F]+") // Regexp used to validate the response header content
	// 		})
	// 		apidsl.Required("X-Request-Id") // Header is mandatory
	// 	})
	// })

})
